// 通用加载组件
function LoadingSpinner({ size = 'md', text = '加载中...', className = '' }) {
    const sizeClasses = {
        sm: 'h-4 w-4',
        md: 'h-8 w-8',
        lg: 'h-12 w-12',
        xl: 'h-16 w-16'
    };

    return React.createElement('div', { 
        className: `flex flex-col items-center justify-center gap-2 ${className}` 
    },
        React.createElement('div', {
            className: `animate-spin rounded-full border-2 border-gray-300 border-t-blue-600 ${sizeClasses[size]}`
        }),
        text && React.createElement('p', { 
            className: 'text-sm text-gray-600' 
        }, text)
    );
}

// 通用空状态组件
function EmptyState({ 
    icon = '📭', 
    title = '暂无数据', 
    description = '当前没有可显示的内容',
    action = null,
    className = ''
}) {
    return React.createElement('div', { 
        className: `flex flex-col items-center justify-center py-12 text-center ${className}` 
    },
        React.createElement('div', { 
            className: 'text-6xl mb-4' 
        }, icon),
        React.createElement('h3', { 
            className: 'text-lg font-medium text-gray-900 mb-2' 
        }, title),
        React.createElement('p', { 
            className: 'text-gray-500 mb-4' 
        }, description),
        action && React.createElement('div', null, action)
    );
}

// 通用错误状态组件
function ErrorState({ 
    title = '出现错误', 
    description = '加载数据时出现错误，请稍后重试',
    onRetry = null,
    className = ''
}) {
    return React.createElement('div', { 
        className: `flex flex-col items-center justify-center py-12 text-center ${className}` 
    },
        React.createElement('div', { 
            className: 'text-6xl mb-4' 
        }, '⚠️'),
        React.createElement('h3', { 
            className: 'text-lg font-medium text-red-600 mb-2' 
        }, title),
        React.createElement('p', { 
            className: 'text-gray-500 mb-4' 
        }, description),
        onRetry && React.createElement('button', {
            onClick: onRetry,
            className: 'px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600'
        }, '重试')
    );
}

// 通用确认对话框
function ConfirmDialog({ 
    isOpen, 
    onClose, 
    onConfirm, 
    title = '确认操作',
    message = '您确定要执行此操作吗？',
    confirmText = '确认',
    cancelText = '取消',
    type = 'warning'
}) {
    if (!isOpen) return null;

    const typeIcons = {
        warning: '⚠️',
        danger: '🗑️',
        info: 'ℹ️'
    };

    const typeColors = {
        warning: 'text-yellow-600',
        danger: 'text-red-600',
        info: 'text-blue-600'
    };

    return React.createElement('div', { 
        className: 'fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50' 
    },
        React.createElement('div', { 
            className: 'bg-white rounded-lg shadow-xl max-w-md w-full mx-4' 
        },
            React.createElement('div', { className: 'p-6' },
                React.createElement('div', { className: 'flex items-center mb-4' },
                    React.createElement('span', { 
                        className: `text-2xl mr-3 ${typeColors[type]}` 
                    }, typeIcons[type]),
                    React.createElement('h3', { 
                        className: 'text-lg font-medium text-gray-900' 
                    }, title)
                ),
                React.createElement('p', { 
                    className: 'text-gray-600 mb-6' 
                }, message),
                React.createElement('div', { 
                    className: 'flex justify-end gap-3' 
                },
                    React.createElement('button', {
                        onClick: onClose,
                        className: 'px-4 py-2 text-gray-600 border border-gray-300 rounded hover:bg-gray-50'
                    }, cancelText),
                    React.createElement('button', {
                        onClick: onConfirm,
                        className: `px-4 py-2 text-white rounded ${
                            type === 'danger' ? 'bg-red-500 hover:bg-red-600' : 'bg-blue-500 hover:bg-blue-600'
                        }`
                    }, confirmText)
                )
            )
        )
    );
}

// 注册到全局作用域
window.LoadingSpinner = LoadingSpinner;
window.EmptyState = EmptyState;
window.ErrorState = ErrorState;
window.ConfirmDialog = ConfirmDialog;
